package com.ft.oa.web.project;

import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.domain.project.ExecProjectTask;
import com.ft.oa.service.project.ExecProjectTaskService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 项目立项任务
 * @author hefeng
 * @ClassName ExecProjectTaskController
 * @date 2022/1/6 16:48
 */
@RestController
@RequestMapping("/execProjectTask")
public class ExecProjectTaskController {

    @Resource
    private ExecProjectTaskService execProjectTaskService;

    /**
     * 新建立项任务
     * @param execProjectTask
     * @return
     */
    @PostMapping("/add")
    public ApiResult add(@RequestBody ExecProjectTask execProjectTask){
        return execProjectTaskService.add(execProjectTask);
    }

    /**
     * 编辑立项任务
     * @param execProjectTask
     * @return
     */
    @PostMapping("/update")
    public ApiResult update(@RequestBody ExecProjectTask execProjectTask){
        return execProjectTaskService.update(execProjectTask);
    }

    /**
     * 项目任务详情
     * @param id
     * @return
     */
    @GetMapping("/detail")
    public ApiResult detail(@RequestParam Long id){
        return ApiResult.successWithData(execProjectTaskService.detail(id));
    }

    /**
     * 项目任务列表
     * @param name 任务名称
     * @param execProjectId 立项项目id
     * @param execProjectName 立项项目名称
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/list")
    public ApiResult list(@RequestParam(required = false) String name,
                          @RequestParam(required = false) Long execProjectId,
                          @RequestParam(required = false) String execProjectName,
                          @RequestParam int page,
                          @RequestParam int size){
        return ApiResult.successWithData(execProjectTaskService.list(name, execProjectId, execProjectName, page, size));
    }

    /**
     * 项目任务删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public ApiResult del(@RequestParam Long id){
        return ApiResult.successWithData(execProjectTaskService.del(id));
    }
}
